<!-- 设置费用明细 -->
<template>
  <div class="details-dialog">
    <el-dialog width="600px" class top="6vh" title="设置费用明细" :visible="myVisible" @close="close">
      <h3>费用</h3>
      <el-form :inline="true" label-width="100px" size="mini">
        <el-form-item v-for="(item, index) in feeData" :key="index" :label="item.feeName">
            <el-input @blur="addMoenyYF()" style="width: 100px;" v-model="item.money"></el-input>
        </el-form-item>
      </el-form>
      <h3>船代费用</h3>
      <el-form :inline="true" label-width="100px" size="mini">
        <el-form-item v-for="(item, index) in shipData" :key="index" :label="item.feeName">
            <el-input @blur="addMoenyYF()" style="width: 100px;" v-model="item.money"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="info" @click="close" size="mini">关 闭</el-button>
        <el-button type="success" @click="addFee" size="mini">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  // GetputBoxFee,
  updatePutBoxCost
} from '../api/putBoxManage'
export default {
  data () {
    return {
      myVisible: this.visible,
      feeData: [],
      shipData: []
    }
  },
  props: {
    visible: {
      tpye: Boolean,
      default: false
    },
    tableIndexData: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  watch: {
    visible (value) {
      this.myVisible = value
      this.feeData = this.tableIndexData.feedata
      this.shipData = this.tableIndexData.shipFee
      // this.getFee()
    },
    myVisible (value) {
      this.$emit('visibleChange', value)
    }
  },
  methods: {
    // async getFee () {
    //   let res = await GetputBoxFee({
    //     putBoxId: this.tableIndexData.putBoxId
    //   })
    //   this.feeData = res.data
    // },
    async addFee () {
      let res = await updatePutBoxCost({
        userCode: this.tableIndexData.userCode,
        type: this.tableIndexData.type,
        boxCostList: this.feeData,
        shipFee: this.shipData
      })
      if (res.status === 200) {
        this.$notify({
          title: '修改成功',
          message: '修改成功',
          type: 'success',
          duration: 1000
        })
        this.$emit('getTableData')
        this.close()
      } else {
        this.$notify.error({
          title: '错误',
          message: res.msg,
          duration: 1000
        })
      }
    },
    close () {
      this.myVisible = false
    }
  }
}
</script>

<style scoped lang="less">
</style>
